from api.ihrm_api import IHRMApi
from api.kdtx_api import KDTXApi

class TokenUtil:
    # 封装获取用户的token
    @classmethod
    def get_token(cls):
        # 获取uuid
        code_resp = KDTXApi.get_code_api()
        uuid = code_resp.json().get("uuid")
        # 登录接口
        login_body = {
            "username": "admin",
            "password": "HM_2023_test",
            "code": "2",
            "uuid": uuid
        }
        login_resp = KDTXApi.login_api(login_body)
        token = login_resp.json().get("token")
        return token

    @classmethod
    def get_ihrm_token(self):
        body = {"mobile": "13800000002", "password": "123456"}
        resp = IHRMApi.login_api(body)
        token =resp.json().get("data")
        return token


if __name__ == '__main__':
    print(TokenUtil.get_ihrm_token())
